package com.bocai.eelly.utils;

import android.content.Context;
import android.view.Gravity;
import android.widget.BaseAdapter;

import com.orhanobut.dialogplus.DialogPlus;
import com.orhanobut.dialogplus.GridHolder;
import com.orhanobut.dialogplus.OnClickListener;
import com.orhanobut.dialogplus.OnItemClickListener;
import com.orhanobut.dialogplus.ViewHolder;

public class DialogUtil {

    public static void showDialog(Context context, BaseAdapter adapter, OnItemClickListener onItemClickListener){

        DialogPlus dialog = DialogPlus.newDialog(context)
                .setAdapter(adapter)
                .setOnItemClickListener(onItemClickListener)
                .setGravity(Gravity.CENTER)
                .setExpanded(false)  // This will enable the expand feature, (similar to android L share dialog)
                .create();
        dialog.show();

    }

    public static void showGridViewDialog(Context context, BaseAdapter adapter, OnItemClickListener onItemClickListener){

        DialogPlus dialog = DialogPlus.newDialog(context)
                .setAdapter(adapter)
                .setContentHolder(new GridHolder(3))
                .setOnItemClickListener(onItemClickListener)
                .setGravity(Gravity.CENTER)
                .setExpanded(false)  // This will enable the expand feature, (similar to android L share dialog)
                .create();
        dialog.show();

    }

    public static void showLayoutDialog(Context context, int  layout, OnClickListener onClickListener){

        DialogPlus dialog = DialogPlus.newDialog(context)
                .setContentHolder(new ViewHolder(layout))
                .setOnClickListener(onClickListener)
                .setGravity(Gravity.CENTER)
                .setExpanded(false)  // This will enable the expand feature, (similar to android L share dialog)
                .create();
        dialog.show();

    }
}
